3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next |
This section gives the 3DMF specification of the Trimesh object. Trimesh binary metafiles implement a simple type of compression, using a scheme described below.
Normally a Trimesh also has one or more AttributeArray subobjects. For details, see "Attribute Arrays" .
The following auxiliary data structures are used to specify trimeshes. They are mirror images of the similarly-named structures in the file QD3DGeometry.h. See 3D Graphics Programming With QuickDraw 3D 1.5 for a detailed description.
typedef struct TriMeshTriangleData {
Uns32 pointIndices[3];
} TriMeshTriangleData;
typedef struct TriMeshEdgeData {
Uns32 pointIndices[2];
Uns32 triangleIndices[2];
} TriMeshEdgeData;
typedef struct BoundingBox {
Point3D min;
Point3D max;
Boolean isEmpty;
} BoundingBox;
Uns32 numTriangles
Uns32 numTriangleAttributeTypes
Uns32 numEdges
Uns32 numEdgeAttributeTypes
Uns32 numPoints
Uns32 numVertexAttributeTypes
TriMeshTriangleData triangles[numTriangles]
TriMeshEdgeData edges[numEdges]
Point3D points[numPoints]
BoundingBox bBox
The triangles and edges fields in a trimesh are compressed. These fields are arrays of indices into arrays of elements; the maximum value of the indices depends on the size of the array of elements. Hence, the maximum value of an index in the TriMeshTriangleData field pointIndices is equal to numPoints . The same is true for the pointIndices field of TriMeshEdgeData ; the maximum value of an index in the triangleIndices field is numTriangles . Compression is performed as follows:
The triangleIndices field of TriMeshEdgeData has, in addition, the following special case. If a side of an edge does not have a triangle (as is the case if the edge is on a boundary), this is indicated in the trimesh data structure by the constant kQ3ArrayIndexNULL . Since this is a 32-bit quantity, you may need to compress it. Do this by writing kQ3ArrayIndexNULL as follows:
For an example of a trimesh text metafile, see "Attribute Arrays" .
Previous | QD3D Book | Overview | Chapter Contents | Next |